home *** CD-ROM | disk | FTP | other *** search
- /** VLTPhoneModify.rexx
- *
- * Create or Modify an entry in the VLT PhoneBook
- *
- * By W.G.J. Langeveld, February 1992.
- *
- **/
- parse arg action
- /*
- * Add libraries if necessary
- */
- if show("l", "rexxarplib.library") = 0 then do
- check = addlib('rexxsupport.library', 0, -30, 0)
- check = addlib('rexxarplib.library', 0, -30, 0)
- end
- /*
- * Get VLT port, screen name and size
- */
- vltport = address()
- cols = ScreenCols(vltport)
- if cols == -1 then do
- vltscreen = ""
- cols = ScreenCols()
- rows = ScreenRows()
- end
- else do
- vltscreen = vltport
- rows = ScreenRows(vltscreen)
- end
- /*
- * Check if we're set up right
- */
- call pragma('W','NULL')
-
- if ~exists("VLTPhoneBook:") then do
- "@VLTPhoneSetup.rexx"
- exit
- end
- /*
- * If this is a modify, which entry?
- */
- changes. = ""
- if upper(action) = "MODIFY" then do
- filename = GetFile(80, 50, "VLTPhoneBook:",, "Entry Name:", vltscreen)
- if filename == "" then exit
- /*
- * Open it
- */
- if open(input, filename, "r") = 0 then do
- "message (Couldn't read file); delay 1.5; message"
- exit
- end
- /*
- * Read it.
- */
- do i = 1 to 10
- changes.i = readln(input)
- end
- call close(input)
- end
- else do
- changes.4 = "ATDT"
- changes.5 = "ATZ"
- changes.6 = "9600"
- changes.7 = "8N1"
- end
- /*
- * Make a new port name
- */
- do i = 1
- hostname = VLTPHONEMOD || i
- if showlist('p', hostname) = 0 then leave
- end
- portname = hostname || "PORT"
- /*
- * Set up a host.
- */
- address AREXX "'x = CreateHost("hostname", "portname" , "vltscreen")'"
- /*
- * Wait until it is ready.
- */
- do i = 1
- if showlist('p', hostname) ~= 0 then leave
- call delay 30
- end
-
- call SetReqColor(hostname, BACKGROUNDPEN, 0)
- /*
- * Open the port that messages will come to
- */
- mp = openport(portname)
- /*
- * Open the window
- */
- idcmp = 'CLOSEWINDOW+GADGETUP'
- flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
- title = "VLTPhoneBook "action" Entry"
- call OpenWindow(hostname, cols - 600, rows - 200, 450, 200, idcmp, ,
- flags, title)
- /*
- * Add the gadgets
- */
- prompts = "\\Name:\\Address:\\City etc.:"
- prompts = prompts || "\\Phone Number: Modem Init:"
- prompts = prompts || "\\Modem Speed: Parity:"
- prompts = prompts || "\\Predial Cmds:\\Postdial Cmds:\\Notes:"
-
- call WindowText(hostname, prompts)
-
- call AddGadget(hostname, 140, 36, 1, changes.1, "%d%1%g", 290, RIDGEBORDER)
- call AddGadget(hostname, 140, 54, 2, changes.2, "%d%1%g", 290, RIDGEBORDER)
- call AddGadget(hostname, 140, 72, 3, changes.3, "%d%1%g", 290, RIDGEBORDER)
- call AddGadget(hostname, 140, 90, 4, changes.4, "%d%1%g", 96, RIDGEBORDER)
- call AddGadget(hostname, 342, 90, 5, changes.5, "%d%1%g", 88, RIDGEBORDER)
- call AddGadget(hostname, 140, 108, 6, changes.6, "%d%1%g", 96, RIDGEBORDER)
- call AddGadget(hostname, 342, 108, 7, changes.7, "%d%1%g", 88, RIDGEBORDER)
- call AddGadget(hostname, 140, 126, 8, changes.8, "%d%1%g", 290, RIDGEBORDER)
- call AddGadget(hostname, 140, 144, 9, changes.9, "%d%1%g", 290, RIDGEBORDER)
- call AddGadget(hostname, 140, 162, 10, changes.10, "%d%1%g", 290, RIDGEBORDER)
-
- call AddGadget(hostname, 22, 183, 11, " Okay ", "OKAY")
- call AddGadget(hostname, 362, 183, 12, " Cancel ", "CANCEL")
-
- call ActivateGadget(hostname, 1)
- /*
- * Main event loop
- */
- quitflag = 0
- finalpass = 0
-
- do forever
- if quitflag = 1 then leave
- t = waitpkt(portname)
- do forever
- p = getpkt(portname)
- if c2d(p) = 0 then leave
-
- cmd = getarg(p)
- if datatype(cmd, 'W') ~= 0 then string = getarg(p, 1)
-
- t = reply(p, 0)
- /*
- * See what we got
- */
- if finalpass = 0 then do
- if cmd = CLOSEWINDOW then do
- call CloseWindow(hostname)
- quitflag = 1
- end
- else if cmd = OKAY then do
- /*
- * Send read requests for all gadgets and set up for second pass
- */
- do i = 1 to 10
- call ReadGadget(hostname, i)
- end
- finalpass = 1
- end
- else if cmd = CANCEL then do
- call CloseWindow(hostname)
- quitflag = 1
- end
- else do
- if datatype(cmd, 'W') ~= 0 then do
- cmd = cmd + 1
- if cmd > 10 then cmd = 1
- call ActivateGadget(hostname, cmd)
- end
- end
- end
- else do
- /*
- * Second pass. We're reading the gadgets
- */
- if datatype(cmd, 'W') ~= 0 then do
- changes.cmd = string
- if cmd = 10 then do
- call CloseWindow(hostname)
- quitflag = 1
- end
- end
- end
- end
- end
-
- /*
- * Write out the modified data
- */
- if finalpass = 1 then do
- if upper(action) ~= "MODIFY" then do
- filename = GetFile(80, 50, "VLTPhoneBook:",, "New Entry Name:", ,
- vltscreen,,,"SAVE")
- if filename == "" then exit
- end
-
- if open(output, filename, "w") = 0 then do
- "message (Couldn't write file); delay 1.5; message"
- exit
- end
-
- do i = 1 to 10
- writeln(output, changes.i)
- end
-
- call close(output)
- end
-
- exit
-
-